import {
    Form,
    DatePicker,
    Divider,
    Input,
    Select,
    Space,
    Button,
    InputRef,
} from 'antd';
import React, { useState, useRef } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { useMount } from 'ahooks';
import dayjs from 'dayjs';
import './index.scss';

const PlatformAddressInfo = (props: any) => {
    const { formModal, rowItem } = props;
    const { modal, form } = formModal;

    const classifyOption = [
        { label: '测试平台', value: 2 },
        { label: '内部系统平台', value: 3 },
        { label: '研发工具平台', value: 4 },
        { label: '外部工具', value: 5 },
    ];

    useMount(() => {
        const {
            deptName,
            classifyId,
            favicon,
            platformDesc,
            platformName,
            preEnv,
            prodEnv,
            testEnv,
            ...rest
        } = rowItem;

        form.setFieldsValue({
            deptName: deptName ?? '',
            classifyId: classifyId ?? '',
            favicon: favicon ?? '',
            platformDesc: platformDesc ?? '',
            platformName: platformName ?? '',
            preEnv: preEnv ?? '',
            prodEnv: prodEnv ?? '',
            testEnv: testEnv ?? '',
            ...rest,
        });
    });

    return (
        <>
            <Form
                name="editSupplierInfo"
                labelCol={{ span: 6 }}
                wrapperCol={{ span: 18 }}
                form={form}
            >
                <div>
                    <div className="form-item">
                        {/* 发布计划 */}
                        <Form.Item
                            label="平台名称"
                            name="platformName"
                            className="form-item-box-50"
                            rules={[
                                {
                                    required: false,
                                    message: '请输入',
                                },
                            ]}
                        >
                            <Input type="text" placeholder="请输入" />
                        </Form.Item>
                        <Form.Item
                            label="归属部门"
                            name="deptName"
                            className="form-item-box-50"
                            rules={[{ required: false, message: '请输入' }]}
                        >
                            <Input type="text" placeholder="请输入" />
                        </Form.Item>
                        <Form.Item
                            label="平台分类"
                            name="classifyId"
                            className="form-item-box-50"
                            rules={[{ required: true, message: '请选择' }]}
                        >
                            <Select
                                placeholder="请选择"
                                options={classifyOption}
                            />
                        </Form.Item>
                        <Form.Item
                            label="测试环境"
                            name="testEnv"
                            className="form-item-box-50"
                            rules={[{ required: false, message: '请输入' }]}
                        >
                            <Input placeholder="请输入" />
                        </Form.Item>
                        <Form.Item
                            label="预发环境"
                            name="preEnv"
                            className="form-item-box-50"
                            rules={[{ required: false, message: '请输入' }]}
                        >
                            <Input placeholder="请输入" />
                        </Form.Item>
                        <Form.Item
                            label="线上环境"
                            name="prodEnv"
                            className="form-item-box-50"
                            rules={[{ required: false, message: '请输入' }]}
                        >
                            <Input placeholder="请输入" />
                        </Form.Item>
                        <Form.Item
                            label="logo地址"
                            name="favicon"
                            className="form-item-box-50"
                            rules={[
                                { required: true, message: '开发负责人必填！' },
                            ]}
                        >
                            <Input placeholder="请输入技术方案链接" />
                        </Form.Item>

                        <Form.Item
                            label="平台描述"
                            name="platformDesc"
                            className="form-item-box-50"
                            rules={[{ required: false, message: '请输入' }]}
                        >
                            <Input.TextArea rows={5} placeholder="请输入" />
                        </Form.Item>
                    </div>
                </div>
            </Form>
        </>
    );
};
export default PlatformAddressInfo;
